{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">上标题：</label>
                            <div class="layui-input-block">
                                <textarea name="pb_title_up" placeholder="文字介绍" class="layui-input" style="height: 100px;"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">下标题：</label>
                            <div class="layui-input-block">
                                <input type="text" name="pb_title" placeholder="标题" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">展示位置：</label>
                            <div class="layui-input-block">
                                <select name="pb_where">
                                    {if $type == 1}
                                    <option value="1" selected>轮播图</option>
                                    <option value="2">案例相册</option>
                                    <option value="3">现场照片</option>
                                    {else /}
                                    <option value="4">案例视频</option>
                                    {/if}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group" id="banner_fid">
                            <label class="layui-form-label">类型：</label>
                            <div class="layui-input-block">
                                <select name="pb_type">
                                    {if $type == 1}
                                    <option value="1" selected>图文</option>
                                    {/if}
                                    {if $type == 2}
                                    <option value="2" selected>视频</option>
                                    {/if}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10" id="image_1">
                            <label class="layui-form-label">{$type != 2 ? '图片' : '视频'}：</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="cpd_content1" id="photo" lay-verify="image">
                                <div id="uploader" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker"></div>
                                            <p>或将{$type != 2 ? '图片' : '视频'}拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">排序：</label>
                            <div class="layui-input-block">
                                <input type="text" value="1" name="pb_sort" lay-verify="required" placeholder="排序" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">添加
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="wk.layer_close('close')">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" id="ttyy" value="{$type}" />
{include file="public/footer" /}
<script>
    var ttyy = $('#ttyy').val();
    if(ttyy != 2){
        var numnum = 30;
        if(ttyy == 3){
            numnum = 1;
        }
        var n = wk.uploads({num:numnum,type:'png,jpg,jpeg',url:"{:url('admin/upload/upload')}"}); //图片
        function imgDel(e,obj){
            wk.uploads_del(e,obj,n); // 删除
        }
    }else{
        var n = wk.uploads({num:30,size:200,type:'mp4,MP4,Mp4,mP4',url:"{:url('admin/upload/upload')}",mwwadd:2}); //视频
        function imgDel(e,obj){
            wk.uploads_del(e,obj,n); // 删除
        }
    }

    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('bannerAdd')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                            wk.layer_close();
                        })
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>

</body>
</html>
